﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MvcApp
{
    // 注意: 如需啟用 IIS6 或 IIS7 傳統模式的說明， 
    // 請造訪 http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute("NoAction", "{controller}", new { controller = "home", action = "index", id = "" });//无Action的匹配
            //routes.MapRoute("NoID", "{controller}/{action}", new { controller = "home", action = "index", id = "" });//无ID的匹配

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

            //routes.MapRoute("Root", "", new { controller = "home", action = "index", id = "" });//根目录匹配
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}